package com.wust.loveangel;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.wust.R;
import com.wust.data.Data;
import com.wust.data.DataDao;
import com.wust.loveangel.loveAngelActivity4.OnListener;
import com.wust.menu.ThirdGroupTab;

public class loveAngelActivity5 extends Activity {
	private TextView titleview;
	private TextView contentview;
	private Button loveangel_back=null;
	private Button backbtn;
	private String id5;
	private String id4;
	private String id2;
	private String id3;
	private DataDao dataDao;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.loveangel_content);
		titleview=(TextView)findViewById(R.id.loveangel_content_title);
		contentview=(TextView)findViewById(R.id.loveangel_content_main);
		backbtn=(Button)findViewById(R.id.loveangel_back);
		Intent intent=getIntent();
		id4=intent.getStringExtra("id4");
		id2=intent.getStringExtra("id2");
		id3=intent.getStringExtra("id3");
		id5=intent.getStringExtra("msg");
		dataDao=new DataDao(this);
		Data data=dataDao.getDataId(id5);
		titleview.setText(data.getTitle());
		contentview.setText(data.getContent());
		loveangel_back=(Button)findViewById(R.id.loveangel_back);
		loveangel_back.setOnClickListener(new OnListener());
	}
	private void back(){
		//把后退事件交给子Activity处理  
		Intent intent = new Intent(loveAngelActivity5.this, loveAngelActivity4.class);  
		intent.putExtra("msg", id4);
		intent.putExtra("id3", id3);
		intent.putExtra("id2", id2);
		// 把Activity转换成一个Window，然后转换成View  
		Window w = ThirdGroupTab.group.getLocalActivityManager()  
		                .startActivity("loveAngelActivity5",intent);  
		View view = w.getDecorView();  
	    //设置要跳转的Activity显示为本ActivityGroup的内容  
		ThirdGroupTab.group.setContentView(view);  
	}
	@Override  
    public void onBackPressed() {   
        back();
    } 
	class OnListener implements OnClickListener{
    	@Override
    	public void onClick(View v) {
    		// TODO Auto-generated method stub
    		back();
    	}
    }
}
